package algorithm.view.prepare;

import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;


/**
 * @author bingo
 * @Description
 * @Date 2018/7/20
 */
public class Demo2 {
    public static void main(String[] args) {
        Frame f = new Frame();
        TextArea ta = new TextArea(20,40);
        TextField tf = new TextField(20);
        f.setSize(400,400);
        f.setVisible(true);
        f.addWindowListener(new WindowAdapter() {
            @Override
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        f.setLayout(new FlowLayout());
        Button button = new Button("ewrt");

        f.add(tf);
        f.add(button);
        f.add(ta);
        button.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e){
                String str = tf.getText().trim();
                tf.setText("");
                ta.append(str+"\r\n");
                tf.requestFocus();
            }
        });
    }
}
